import { Component, OnInit } from '@angular/core';
import { LocalStorage } from '@core/local.storage';
import { Router, ActivatedRoute } from '@angular/router';
import { _HttpClient } from '@delon/theme';
import { environment } from '../../../../environments/environment';
@Component({
    selector: 'app-stationdetail',
    templateUrl: './stationDetail.component.html',
    styleUrls: ['./dispatchList.component.less']
})
export class StationDetailComponent implements OnInit {
    rowThree = { 'display': 'inline-block', 'width': '150px', 'text-align': 'right' };
    queryParams: any = {};
    skywinList: any = [];
    problemList: any = [];
    peopleList: any;
    readStatus = true;

    constructor(
        private activatedRoute: ActivatedRoute,
        public ls: LocalStorage,
        private router: Router,
        private http: _HttpClient
    ) { }

    ngOnInit() {
        this.activatedRoute.queryParams.subscribe(param => {
            Object.assign(this.queryParams, param);
            if (this.queryParams.vcTeammenberid) {
                this.queryParams.vcTeammenberid = this.queryParams.vcTeammenberid.split(',');
            }
            // 人员
            this.http.post(environment.devscore + '/orgPerson/queryList', { orgId: this.queryParams.vcOrgId, qualifictionId: '1' }).subscribe((res: any) => {
                if (!res.code) {
                    this.peopleList = res.data;
                }
            });
        });
        this.http.get(environment.project + '/dayWorkSgrwxkm/query?vcSta=' + this.queryParams.vcStaid + '&dtWorkDay=' + this.queryParams.dtWorkdate + '&orgId=' + this.queryParams.vcOrgId).subscribe((res: any) => {
            this.skywinList = res.meta.list;
        });
        let undone = '';
        undone = !this.queryParams.vcDevgroupId ? environment.project + '/safeProblem/queryUndone?devId=' + this.queryParams.vcDevid + '&stationId=' + this.queryParams.vcStaid : environment.project + '/safeProblem/queryUndone?stationId=' + this.queryParams.vcStaid;

        this.http.get(undone).subscribe((res: any) => {
            this.problemList = res;
            if (this.queryParams.vcProbids) {
                for (const item of this.problemList.data) {
                    if (this.queryParams.vcProbids.indexOf(item.id) !== -1) {
                        item.checked = true;
                    }
                }
            }
        });
    }
    back() {
        this.router.navigate(['dispatchList/' + this.queryParams.typeName]);
    }
}
